home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / MACVOGL- / GETCHAR.C < prev    next >
C/C++ Source or Header  |  1992-07-19  |  860b  |  59 lines

  1. #include <stdio.h>
  2.  
  3. #ifdef SGI
  4. #include <gl.h>
  5. #include <device.h>
  6. #else
  7. #include "vogl.h"
  8. #include "vodevice.h"
  9. #endif
  10.  
  11. /*
  12.  * getcharacter
  13.  *
  14.  *    read in a character line from a hershey font file
  15.  */
  16. int
  17. getcharacter(fp, no, pairs, buf)
  18.     FILE    *fp;
  19.     int    *no, *pairs;
  20.     char    *buf;
  21. {
  22.     int    i;
  23.     char    *p, tmp[10];
  24.  
  25.     /*
  26.      * read in the numbers
  27.      */
  28.     for (i = 0; i < 5; i++) {
  29.         if ((tmp[i] = fgetc(fp)) == '\n')    /* take care of the odd blank line */
  30.             tmp[i] = fgetc(fp);
  31.         if (feof(fp))
  32.             return(0);
  33.     }
  34.     tmp[5] = 0;
  35.     sscanf(tmp, "%d", no);
  36.         
  37.     for (i = 0; i < 3; i++) {
  38.         tmp[i] = fgetc(fp);
  39.         if (feof(fp))
  40.             return(0);
  41.     }
  42.     tmp[3] = 0;
  43.     sscanf(tmp, "%d", pairs);
  44.         
  45.  
  46.     /*
  47.      * read in the pairs
  48.      */
  49.     for (p = buf, i = 0; i < 2 * *pairs; i++, p++)
  50.         if ((*p = fgetc(fp)) == '\n')
  51.             *p = fgetc(fp);
  52.  
  53.     *p = 0;
  54.  
  55.     fgetc(fp);            /* skip newline at end */
  56.  
  57.     return(1);
  58. }
  59.